<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<canvas id="canvas" width="200" height="200"></canvas>

<script>
test(function(t) {
    var ctx = document.getElementById('canvas').getContext('2d');
    ctx.fillStyle = 'rgba(255, 0, 0, 0.01)';
    ctx.fillRect(0, 0, 1, 200);
    ctx.fillStyle = 'rgba(0, 255, 0, 0.995)';
    ctx.fillRect(1, 0, 199, 200);

    var imageData = ctx.getImageData(0, 0, 200, 200);
    var imgdata = imageData.data;
    assert_equals(imgdata[4], 0);
    assert_equals(imgdata[5], 255);
    assert_equals(imgdata[6], 0);
    assert_equals(imgdata[7], 254);

    ctx.putImageData(imageData, 0, 0);
    imgdata = ctx.getImageData(0, 0, 200, 200).data;
    assert_equals(imgdata[4], 0);
    assert_equals(imgdata[5], 255);
    assert_equals(imgdata[6], 0);
    assert_equals(imgdata[7], 254);
}, 'Series of tests to ensure correct behaviour of getImageData and putImageData when alpha is involved.');
</script>
